'use strict'

var xss = require('xss')
var mongoose = require('mongoose')
// var schema = new mongoose.Schema({ num:Number, name: String, size: String })
// var myModel = mongoose.model('mymodels', schema)
// var ceshi = mongoose.model('MyModels')
// var ceshi = mongoose.model('ceshi001', {num:Number, name: String, size: String});



exports.mGet01 = function *(next) {
  // var schema = new mongoose.Schema({ num:Number, name: String, size: String });
  // schema.methods.findSimilarSizes = function(cb){
  //     return this.model('MyModel').find({size:this.size},cb);
  // }
  // var MyModel = mongoose.model('MyModel', schema);
  // var doc1 = new MyModel({ name:'doc1', size: 'small' });
  // var doc2 = new MyModel({ name:'doc2', size: 'small' });
  // var doc3 = new MyModel({ name:'doc3', size: 'big' });
  // doc1.save();
  // doc2.save();
  // doc3.save();
  // setTimeout(function(){
  //     doc1.findSimilarSizes(function(err,docs){
  //         docs.forEach(function(item,index,arr){
  //             //doc1
  //             //doc2
  //               console.log(item.name)
  //         })
  //   })
  // },0)
  var user = yield myModels.findOne({
    name: 'doc3'
  })
  console.log(user);
  this.body = {
    success: true,
    data: {
      nickname: '小狗宝',
      avatar: 'http://res.cloudinary.com/gougou/image/upload/mooc1.png',
      phoneNumber: '21321312321',
      verifyCode: 'verifyCode',
      accessToken: 'accessToken'
    }
  }
}

exports.mGet02 = function *(next) {
  this.body = {
    success: true,
    data: {
      name: '呵呵呵呵'
    }
  }
}